home *** CD-ROM | disk | FTP | other *** search
/ Ultra Gameplayers 101 / Ultra Game Players Magazine, No. 101 - September 1997 (Imagine Publishing, Inc.)(1997).iso / pc / new_ugp.dxr / 00348.ls < prev    next >
Encoding:
Text File  |  1997-07-10  |  1.3 KB  |  43 lines

  1. on importUGPfile target
  2.   set file to new(xtra("FileIO"))
  3.   set fileName to displayOpen(file)
  4.   if fileName = EMPTY then
  5.     exit
  6.   end if
  7.   openFile(file, fileName, 0)
  8.   set errmsg to error(file, status(file))
  9.   if errmsg <> "OK" then
  10.     alert(errmsg)
  11.     exit
  12.   end if
  13.   set filedata to EMPTY
  14.   repeat while 1
  15.     set curline to readLine(file)
  16.     if curline <> EMPTY then
  17.       set filedata to filedata & curline
  18.       next repeat
  19.     end if
  20.     exit repeat
  21.   end repeat
  22.   closeFile(file)
  23.   put "File '" & fileName & "' read."
  24.   put "Now processing data"
  25.   set recprops to ["name", "section", "category", "url", "description", "tag", "filepath", "movie", "image"]
  26.   set numprops to count(recprops)
  27.   put numprops
  28.   set delimiter to TAB
  29.   set buffer to listtotext(recprops, TAB) & RETURN
  30.   repeat while filedata <> EMPTY
  31.     set entry to line 1 to numprops of filedata
  32.     delete line 1 to min(numprops + 1, the number of lines in filedata) of filedata
  33.     set entrylist to texttolist(entry, RETURN)
  34.     put getAt(entrylist, 1)
  35.     set buffer to buffer & listtotext(entrylist, delimiter) & RETURN
  36.   end repeat
  37.   delete char length(buffer) of buffer
  38.   set buffer to replace(buffer, numToChar(10), EMPTY)
  39.   set buffer to replace(buffer, numToChar(9), "|")
  40.   put buffer into field target
  41.   saveMovie()
  42. end
  43.